<template>
  <a-modal v-model="visible"   title="更新统计内容"  @cancel='cancel' @ok='sure'>
    <a-form-model :model="item" :label-col="{span :4 }" :wrapper-col="{ span: 20 }">
      <a-form-model-item label="名称" required>
        <a-input v-model="item.name"  />
      </a-form-model-item>
      <a-form-model-item label="内容" >
        <a-input v-model="item.content" type="textarea" :auto-size="{ minRows: 5 ,maxRows: 5}"/>
      </a-form-model-item>
      <a-form-model-item label=" " >
        <a-checkbox @change="onChange">
          同步更新模板内容
        </a-checkbox>
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import ReportsEpidemicDailyService from '@/myService/ReportsEpidemicDailyService'

export default {
  data(){
    return{
      visible:false,
      title:'',
      item:{},
      flag:false,
    }
  },
  methods:{
    open(item){
      this.item=item;
      this.visible=true
    },
    async cancel() {
      await this.$emit('updateCategory');
      this.visible = false;
    },
    sure(){
      if(this.item.name===''|| this.item.name===undefined ){
        this.$message.error("名称不可为空")
        return;
      }
      let params={
        id:this.item.id,
        categoryId:this.item.categoryId,
        name:this.item.name,
        content:this.item.content,
        flag:this.flag
      }
      ReportsEpidemicDailyService.changeCategoryContent(params).then(res=>{
        if(res.result===true){
          this.$message.success("更新成功")
          this.cancel()
        }
      })
    },
    onChange(e){
      this.flag=e.target.checked
    }
  }
}
</script>

<style scoped>

</style>